/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package be.hogent.iii.project.gui;

import be.hogent.iii.project.dummy.DummySpel;
import java.io.File;
import java.io.FileInputStream;
import java.util.Properties;
import javax.swing.JFrame;
import javax.swing.SwingUtilities;

/**
 * Het frame dat alles panelen bevat. 
 * @author Caribou
 */
public class SpelFrame extends JFrame {

    private static final long serialVersionUID = 1L;
    private static final String PROPERTYFILE = "src\\be\\hogent\\iii\\project\\gui\\vakEigenschappen.properties";
   
    /**
     * Basis constructor. 
     */
    public SpelFrame() {
        super("Project");
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        Properties props = this.loadProperties();
        DummySpel spel = new DummySpel();
        PaneelEventHandler handler = new PaneelEventHandler(spel.getSpel(), props);
        SpelPaneel paneel = new SpelPaneel(spel.getSpel(), props, handler);
        this.setContentPane(paneel);
  
        this.pack();
        this.setVisible(true);   
    }
    
    /**
     * Lees properties file in. 
     * @return properties
     */
    private Properties loadProperties(){
        Properties property = new Properties();
        try {
            File file = new File(PROPERTYFILE);
            property.load(new FileInputStream(file));
        } //catch exception in case properties file does not exist
        catch (Exception e) {
            e.printStackTrace();
        }
        return property;
    }

    /**
     * De methode om het programma te starten
     * @param args
     */
    public static void main(String[] args) {
        SwingUtilities.invokeLater(new Runnable() {

            public void run() {
                //JFrame.setDefaultLookAndFeelDecorated(true);
                new SpelFrame();
            }
        });
    }
}
